import request from './request'

// 获取流程列表
export function getProcessList(params) {
  return request({
    url: '/processes',
    method: 'get',
    params
  })
}

// 创建流程
export function createProcess(data) {
  return request({
    url: '/processes',
    method: 'post',
    data
  })
}

// 获取流程详情
export function getProcessDetail(id) {
  return request({
    url: `/processes/${id}`,
    method: 'get'
  })
}

// 更新流程
export function updateProcess(id, data) {
  return request({
    url: `/processes/${id}`,
    method: 'put',
    data
  })
}

// 删除流程
export function deleteProcess(id) {
  return request({
    url: `/processes/${id}`,
    method: 'delete'
  })
}

// 切换流程状态
export function toggleProcessStatus(id) {
  return request({
    url: `/processes/${id}/toggle`,
    method: 'put'
  })
}

// 获取流程实例列表
export function getProcessInstances(id, params) {
  return request({
    url: `/processes/${id}/instances`,
    method: 'get',
    params
  })
}

// 获取阻塞节点列表
export function getBlockedNodes(params) {
  return request({
    url: '/blocked-nodes',
    method: 'get',
    params
  })
}
